#!/usr/bin/env bash
cd `dirname $0`

url_zipkin_jar="https://dl.bintray.com/openzipkin/maven/io/zipkin/java/zipkin-server/2.10.2/zipkin-server-2.10.2-exec.jar"
_jar="zipkin-server-2.10.2-exec.jar"
if [ ! -f "$_jar" ]; then
	echo "download $_jar"
	wget "$url_zipkin_jar"
	if [ ! "$?" == "0" ]; then
		echo "download fail"
		exit 1
	fi
fi

c_name=zipkin
docker rm -f $c_name &>/dev/null


# dns 通过 配置 /etc/docker/daemon.json来处理
# {
#  "registry-mirrors": [ "https://registry.docker-cn.com", "http://hub-mirror.c.163.com" ],
#  "dns": [ "192.168.31.102" ],
#  "bip": "172.17.0.1/16"
# }

# --dns=192.168.2.147 \

docker run -d \
-v $PWD/$_jar:/home/service.jar \
-e STORAGE_TYPE=mysql \
-e MYSQL_USER=root \
-e MYSQL_PASS=my-secret-ab \
-e MYSQL_HOST=mysql.ms.io \
-e RABBIT_URI="amqp://app_user:gmc123@rabbitmq.ms.io:5672/zipkin" \
--restart=always \
--name=$c_name \
-p 9411:9411 \
delitescere/jdk:8 \
	java \
	-Xmx250M -Xms250M -XX:MaxMetaspaceSize=100M \
	-jar /home/service.jar

docker logs -f $c_name